package errormsg

const (
	SUCCESS = 200
	ERROR   = 500

	// 用户类型的错误
	ERROR_USERNAME_USED         = 1001
	ERROR_PASSWORD_WRONG        = 1002
	ERROR_USER_NOT_EXIST        = 1003
	ERROR_TOKEN_WRONG           = 1004
	ERROR_TOKEN_NOT_EXIST       = 1005
	ERROR_ACCESS_TOKEN_RUNTIME  = 1006
	ERROR_REFRESH_TOKEN_RUNTIME = 1007
	ERROR_TOKEN_TYPE_WRONG      = 1008
	ERROR_USER_NOT_RIGHT        = 1009
	ERROR_USERNAME_OK           = 1010

	// 文章类型的错误
	ERROR_ARTICLE_NOT_EXIST = 2001

	// 分类的错误
	ERROR_CATEGORY_NOT_EXIST = 3001
	ERROR_CATEGORY_NAME_USED = 3002
	ERROR_CATEGORY_NAME_OK   = 3003
)

var ErrorMap = map[int]string{
	SUCCESS: "success",
	ERROR:   "fail",

	ERROR_USERNAME_USED:         "用户名已经被使用",
	ERROR_PASSWORD_WRONG:        "密码错误！",
	ERROR_USER_NOT_EXIST:        "用户名不存在！",
	ERROR_TOKEN_WRONG:           "Token错误",
	ERROR_TOKEN_NOT_EXIST:       "Token不存在",
	ERROR_ACCESS_TOKEN_RUNTIME:  "AccessToken已经超时",
	ERROR_REFRESH_TOKEN_RUNTIME: "RefreshToken已经超时",
	ERROR_TOKEN_TYPE_WRONG:      "Token类型错误",
	ERROR_USER_NOT_RIGHT:        "用户无权限",
	ERROR_USERNAME_OK:           "用户名合法",

	// 文章类型的错误
	ERROR_ARTICLE_NOT_EXIST: "文章不存在！",
	// 分类的错误
	ERROR_CATEGORY_NOT_EXIST: "分类不存在！",
	ERROR_CATEGORY_NAME_USED: "分类已经存在！",
	ERROR_CATEGORY_NAME_OK:   "分类名称可以使用",
}

func GetErrorMsg(code int) string {
	return ErrorMap[code]
}
